﻿@{
    ViewBag.Title = "Add";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model YTCMS.Domain.Entities.module

<div class="page-header">
    <h1>
        模块管理
        <small>
            <i class="icon-double-angle-right"></i>
            新增模块
        </small>
    </h1>
</div><!-- /.page-header -->

<div class="row">
    <div class="col-xs-12">
        <div class="row">
            <div class="col-xs-12 ">

            </div>
        </div>
        <div class="row">
            <div class="col-xs-12">
                <form class="form-horizontal" role="form" id="form1" method="post" action="/ads/add">
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 标题 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.Name, new { @class = "col-xs-10 col-sm-5 required" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Code </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.Code, new { @class = "col-xs-10 col-sm-5 required" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 链接地址 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.Href, new { @class = "col-xs-10 col-sm-5 required" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 排序 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.sort, new { @class = "col-xs-10 col-sm-5 required digits" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 类型 </label>
                        <div class="col-sm-9">
                            @Html.RadioButtonFor(s => s.Type, "WAP") WAP
                            @Html.RadioButtonFor(s => s.Type, "PC", new { @checked = "checked" }) PC
                        </div>
                    </div>
                    <div class="clearfix form-actions">
                        <div class="col-md-offset-3 col-md-9">
                            <button class="btn btn-info" type="button" id="btnSave">
                                <i class="icon-ok bigger-110"></i>
                                新增
                            </button>

                            &nbsp; &nbsp; &nbsp;
                            <button class="btn" type="reset">
                                <i class="icon-undo bigger-110"></i>
                                撤销
                            </button>
                        </div>
                    </div>
                </form>
            </div><!-- /span -->
        </div><!-- /row -->
    </div><!-- /.col -->
</div><!-- /.row -->

<script type="text/javascript">
    $(function () {
        $("#btnSave").click(function () {
            var b = jQuery("#form1").valid();
            if (b) {
                $.post("/Module/add", $("#form1").serialize(), function (data) {
                    if (data.d) {
                        jAlert("新增成功", "提示", function () {
                            location.href = "/Module/index";
                        })
                    }
                    else {
                        jAlert(data.msg, "提示");
                    }
                })
            }
        });
      
    })
</script>